package com.multiple.sources.core.config;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

public class DbContextHolder {
	private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
	private static Map<Object, Object> targetDataSources=new HashMap<Object, Object>();

	public static void setDBType(String dbType) {
		contextHolder.set(dbType);
	}

	public static String getDBType() {
		return (String) contextHolder.get();
	}

	public static void clearDBType() {
		contextHolder.remove();
	}
	
	public static void addDataSources(String name,DataSource dataSource){
		targetDataSources.put(name, dataSource);
	}
	public static DataSource getTargetDataSources(String name){
		return (DataSource) targetDataSources.get(name);
	}
	public static Map<Object, Object> dataSources(){
		return targetDataSources;
	}
}
